package com.jbit.hxy.controller;

import com.jbit.hxy.common.Result;
import com.jbit.hxy.model.dto.SetmealQueryDTO;
import com.jbit.hxy.model.po.WxSetmeal;
import com.jbit.hxy.model.po.WxSetmealDish;
import com.jbit.hxy.service.menu.WxSetmealService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
@RequiredArgsConstructor
@Tag(name = "套餐管理")
public class WxSetmealController {
    private final WxSetmealService wxSetmealService;
    @PostMapping("/list")
    @Operation(summary = "套餐列表", description = "套餐列表")
    public Result list(@RequestBody SetmealQueryDTO setmealQueryDTO) {
        return wxSetmealService.getSetmeal(setmealQueryDTO);

    }
    @PostMapping("/add")
    @Operation(summary = "套餐添加", description = "套餐添加")
    public Result add(@RequestBody WxSetmeal wxSetmeal) {
        return wxSetmealService.addSetmeal(wxSetmeal);

    }
    @PostMapping("/update")
    @Operation(summary = "套餐修改", description = "套餐修改")
    public Result update(@RequestBody WxSetmeal wxSetmeal) {
        return wxSetmealService.updateSetmeal(wxSetmeal);
    }
    @GetMapping("/delete")
    @Operation(summary = "套餐删除", description = "套餐删除")
    public Result delete(@RequestParam("id") Integer id) {
        return wxSetmealService.deleteSetmeal(id);
    }
    @GetMapping("/getSetmealDetail")
    @Operation(summary = "套餐详情", description = "套餐详情")
    public Result getSetmealDetail(@RequestParam("id") Integer id) {
        return wxSetmealService.getSetmealDetail(id);
    }


    @GetMapping("/getDishCountBySetmealId")
    @Operation(summary = "套餐菜品数量", description = "套餐菜品数量")
    public Result getDishCountBySetmealId(@RequestParam("id") Integer id) {
        return wxSetmealService.getDishCountBySetmealId(id);
    }
    @GetMapping("/getDishDetailBySetmealId")
    @Operation(summary = "套餐菜品详情", description = "套餐菜品详情")
    public Result getDishDetailBySetmealId(@RequestParam("id") Integer id) {
        return wxSetmealService.getDishDetailBySetmealId(id);
    }
    @GetMapping("/getSetmealNameById")
    @Operation(summary = "套餐名称", description = "套餐名称")
    public Result getSetmealNameById(@RequestParam("id") Integer id) {
        return wxSetmealService.getSetmealNameById(id);
    }

    @GetMapping("/getSetmealDishBySetmealId")
    @Operation(summary = "套餐菜品", description = "套餐菜品")
    public Result<List<WxSetmealDish>> getSetmealDishBySetmealId(@RequestParam("id") Integer id) {
        return wxSetmealService.getSetmealDishBySetmealId(id);
    }



}
